package br.ita.escolaita.model.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="SERIE")
@NamedQueries({
    @NamedQuery(name = "serie.findAll", query = "SELECT s FROM Serie s"),
    @NamedQuery(name = "serie.find", query = "SELECT s FROM Serie s WHERE s .nome = :nome")
})
public class Serie implements Serializable{

    @Transient
    private static final long serialVersionUID = -1107277513173907387L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column
    private Integer id;

    @Column
    private String nome;

    @Column
    @OneToMany(mappedBy="serie",fetch=FetchType.EAGER)
    private Set<Turma> turma;

    @Column
    @OneToMany(mappedBy="serie",fetch=FetchType.EAGER)
    private Set<Disciplina> disciplina;

    @Column
    private Character status = 'A';

    // Construtor Default
    public Serie(){
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }


    public Character getStatus() {
        return status;
    }

    public void setStatus(Character status) {
        this.status = status;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Serie other = (Serie) obj;
        if ((this.nome == null) ? (other.nome != null) : !this.nome.equals(other.nome)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 43 * hash + (this.nome != null ? this.nome.hashCode() : 0);
        return hash;
    }

    public Set<Turma> getTurma() {
        return turma;
    }

    public void setTurma(Set<Turma> turma) {
        this.turma = turma;
    }

    public Set<Disciplina> getDisciplina() {
        return disciplina;
    }

    public void setDisciplina(Set<Disciplina> disciplina) {
        this.disciplina = disciplina;
    }
}
 
